{extend name="index/index"/}

{block name="main"}
<div class="admin-biaogelist">
	
    <div class="listbiaoti am-cf">
      <ul class="am-icon-flag on"> 广告栏位列表</ul>
      
      <dl class="am-icon-home" style="float: right;">当前位置： 首页 > <a href="#">广告列表</a></dl>
      
      <dl>
        <a type="button" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus" href="{:url('admin/advertisingby/create')}"> 添加广告列表</a>
      </dl>
    </div>

    <form class="am-form am-g">
          <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped am-table-hover">
            <thead>
              <tr class="am-success">
                <th class="table-id">ID</th>
                <th class="table-author am-hide-sm-only">标题</th>
                <th class="table-title">描述</th>
                <th class="table-type">上传图片</th>
                <th class="table-date am-hide-sm-only">上传时间</th>
                <th width="130px" class="table-set">操作</th>
              </tr>
            </thead>
            <tbody>
             {volist name="data" id="v"}
              <tr>
                <td>{$v['id']}</td>
                <td class="am-hide-sm-only">{$v['title']}</td>
                <td>{$v['describe']}</td>
                <td><img src="/uploads/advertisingby/{:str_replace('\','/',$v['upload_path'])}" style="width:100px; height:60px"></td>
                <td class="am-hide-sm-only">{$v['upload_time']}</td>
                <td>
                	<div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                      <a class="am-btn am-btn-default am-btn-xs am-text-secondary am-round" data-am-modal="{target: '#my-popups'}" title="修改订单" href="{:url('admin/Advertisingby/edit',['id'=>$v['id']])}"><span class="am-icon-pencil-square-o" ></span></a>
                      <dev data-id="{$v['id']}" class="am-btn am-btn-default am-btn-xs am-text-danger am-round btn-del" title="删除订单"><span class="am-icon-trash-o" ></span></dev>
                    </div>
                  </div>
                </td>
              </tr>
            {/volist}
            </tbody>
          </table>

          <ul class="am-pagination am-fr">
              {$data->render()}
              </ul>
          <hr />
          <p>注：.....</p>
        </form>
</div>

<script>
    $(function(){
        $('.btn-del').click(function(){
            var ac_id = $(this).attr('data-id');


            if(confirm('你确定要删除这条数据吗？')){
                var obj = $(this).parents('tr');


                //执行Ajax删除的函数
                delAjax(ac_id,obj);
            }
        });

        //执行Ajax删除
        function delAjax(id,obj)
        {
           $.ajax({
               type:'delete',
               dataType:'json',
               url : '/advertising/'+id,
               success: function(data){
                   if (data.status) {
                      alert(data.info);
                       // 将当前的节点删除掉
                       obj.remove();
                   } else {
                      alert(data.info);
                   }
               },
               error: function(){
                   // AJAX操作失败
                   alert('AJAX操作失败');
               },
           });
        }
    });

</script>

{/block}